package com.vhly.apb;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;

/**
 * Created by IntelliJ IDEA.
 * User: vhly[FR]
 * Date: 2010-12-13
 * Time: 23:44:46
 * Email: vhly@163.com
 */
public class AuthorizeActivity extends Activity implements View.OnClickListener {

    private WebView web;
    private EditText txtCode;

    private Intent rtin;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        if (web == null) {
//            web = new WebView(this);
//        }
//        setContentView(web);

        setContentView(R.layout.authorize);
        web = (WebView) findViewById(R.id.web);
        txtCode = (EditText) findViewById(R.id.txtcode);
        Button btn = (Button) findViewById(R.id.btnverify);
        btn.setOnClickListener(this);

        String rau = this.getIntent().getExtras().getString("rau");
        if (rau != null) {
            web.loadUrl(rau);
        }
    }

    public void onClick(View view) {
        String verify = txtCode.getText().toString();
        System.out.println("verify = " + verify);
    }

    @Override
    public void finish() {
        String verify = txtCode.getText().toString();
        if (verify.length() > 0) {
            if (rtin == null) {
                rtin = new Intent();
            }
            rtin.putExtra("verifyCode", verify);
            this.setResult(1, rtin);
        }
        super.finish();
    }
}
